package com.wolfeyes.system.service.impl;

import com.wolfeyes.system.mapper.SysMenuMapper;
import com.wolfeyes.system.service.SysMenuService;
import com.wolfeyes.common.utils.character.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @see Talk is cheap, Show me the code. -- Linus Torvalds
 * @title 选座信息服务层-实现类
 * @author yanyljava
 * @email yanyljava@qq.com
 * @create 2020-09-06 10:21
 */
@Service
public class SysMenuServiceImpl implements SysMenuService {

	@Autowired
	private SysMenuMapper sysMenuMapper;

	@Override
	public Set<String> selectMenuPermsByUserId(Long userId) {
		List<String> perms = sysMenuMapper.selectMenuPermsByUserId(userId);
		Set<String> permsSet = new HashSet<>();
		for (String perm : perms)
		{
			if (StringUtils.isNotEmpty(perm))
			{
				permsSet.addAll(Arrays.asList(perm.trim().split(",")));
			}
		}
		return permsSet;
	}

}
